package com.bstek.demo.service;

import com.bstek.demo.entity.VipInfo;
import com.bstek.urule.model.library.action.annotation.ActionBean;
import com.bstek.urule.model.library.action.annotation.ActionMethod;
import com.bstek.urule.model.library.action.annotation.ActionMethodParameter;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Title: VipInfoAction
 * @Package: com.bstek.demo.test
 * @Description:
 * @Author: zxq
 * @Date: 2023/10/18 - 13:45
 */

@Component("vipInfoAction")
@ActionBean(name="加油站会员")
public class VipInfoAction {

    public static Map<String,List<VipInfo>> vip=new ConcurrentHashMap<>();

    @ActionMethod(name="获取用户的会员信息")
    public List<VipInfo> getVip(String vipNum){
        List<VipInfo> list = vip.get(vipNum);
        if (list==null){
            VipInfo vipInfo = new VipInfo();
            vipInfo.setVipNum(vipNum);
            ArrayList<VipInfo> vipInfos = new ArrayList<>();
//            vipInfos.add(vipInfo);
            vip.put(vipNum,vipInfos);
            return vipInfos;
        }
        return list;
    }

    @ActionMethod(name="添加会员信息")
    @ActionMethodParameter(names={"会员号","会员优惠集"})
    public void addVip(String vipNum,List<VipInfo> list){
        vip.put(vipNum,list);
    }



}
